package com.hxci.liminshuo.servcie;

import com.github.pagehelper.PageHelper;
import com.hxci.liminshuo.dao.MinShuoCourseMapper;
import com.hxci.liminshuo.pojo.MinShuoCourse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class MinShuoCorseServiceImp implements MinShuoCorseService {

    @Autowired
    MinShuoCourseMapper mapper;

    @Override
    public List<MinShuoCourse> query() {
        //return mapper.query();

        System.out.println("=== 开始查询课程数据 ===");
        List<MinShuoCourse> result = mapper.query();
        System.out.println("查询结果数量: " + (result != null ? result.size() : 0));
        if (result != null && !result.isEmpty()) {
            System.out.println("第一条数据: " + result.get(0));
        }
        System.out.println("=== 查询结束 ===");
        return result;
    }

    @Override
    public List<MinShuoCourse> queryByCondition(String keyword) {
        return mapper.queryByCondition(keyword);
    }

    @Override
    public int deleteById(Integer id) {
        if (id == null || id <= 0) return 0;
        return mapper.deleteById(id);
    }

    @Override
    public int insert(MinShuoCourse course) {
        return mapper.insert(course);
    }

    @Override
    public MinShuoCourse selectById(Integer id) {
        return mapper.selectById(id);
    }

    @Override
    public int update(MinShuoCourse course) {
        return mapper.update(course);
    }

    @Override
    public List<MinShuoCourse> queryByPage(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        return mapper.query();
    }

    @Override
    public int batchDelete(List<Integer> ids) {
        return mapper.batchDelete(ids);
    }
}


